<?php

namespace app\index\controller\trade;

use app\index\model\UM as UM;
use app\index\service\TradeLawCaseService;
use app\index\service\TradeLawsuitService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * LawCase 控制器
 * Class LawCase
 * @package app\index\controller\trade;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 */
class Lawsuit
{
    // 请求参数
    private Request $request;
    private TradeLawsuitService $tradeLawsuitService;


    public function __construct(Request $request, TradeLawsuitService $tradeLawsuitService)
    {
        $this->request = $request;
        $this->tradeLawsuitService = $tradeLawsuitService;
    }

    /**
     * 新增|修改
     * @param UM $user
     * @return ApiResponse
     * @url /trade/lawsuit/save
     */
    public function save(UM $user): ApiResponse
    {
        $request = $this->request;

        $data = $this->tradeLawsuitService->add($user, $request->param());

        return ApiResponse::success($data);
    }

}
